@extends('layouts.forum')
@section('title')
    {{$partition->title or ''}}
@endsection

@section('contaier')
    @include('include.forum.top')
    <div class="users-show row font">
        <div class="main-col col-md-9 left-col" style="min-height: 300px;min-width: 870px">
            <div class="panel panel-inverse">
                <div class="panel-heading w100 text-center">
                    @foreach($categorie as $item)
                        <a href="{{url('/forum/plate/'.$partition->id.'?categorie=').$item->categorie->id}}" class="btn btn-inverse btn-xs" style="color: {{$item->categorie->color or 'black'}}">{{$item->categorie->name or 'Error'}}</a>
                    @endforeach
                </div>
                <div class="panel-body">
                    @if (empty($topics))
                        <h3 class="text-center">还没有任何东西</h3>
                    @else
                        @foreach($topics as $topic)
                            <div class="col-md-12 row m-t-5">
                                <div class="col-md-1 p-0">
                                    <a href="{{url('/user/info/'.$topic->user()->first()->id)}}">
                                        <img src="{{cdn($topic->user()->first()->profile)}}" class="w-50 h-50 avatar">
                                    </a>
                                </div>
                                <div class="col-md-11 topic-author-box" style="border-bottom: 1px solid #eee">
                                    <div class="w100">
                                        <a href="{{url('/forum/topic/'.$topic->id)}}" class="thread-title f-s-16 popover-with-html" data-content="{{$topic->title or ''}}" data-original-title="" title="">
                                            <?php $categorie = $topic->categorie ?>
                                            <span style="color: {{$categorie->color}};">[{{$categorie->name}}]</span>{{$topic->title or ''}}
                                        </a>
                                    </div>
                                    <div class="w100 m-b-10" style="color: #999;">
                                        <a href="{{url('/user/info/'.$topic->user()->first()->id)}}">{{$topic->user()->first()->name}}</a>
                                        <div class="pull-right">
                                            <i class="fa fa-eye p-r-10"><span class="font p-l-5">{{$topic->click_count or 0}}</span></i>
                                            <i class="fa fa-comment"><span class="font p-l-5">{{$topic->reply_count or 0}}</span></i>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        @endforeach
                    @endif
                    <div class="m-t-10 pull-right m-r-15">
                        @if ($categorie_id == 0)
                            {{ $topics->links() }}
                        @else
                            {{ $topics->appends(['categorie' => $categorie_id])->links() }}
                        @endif
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-3 p-l-5 p-r-25" style="min-height: 300px;min-width: 292px">
            <div class="box">
                <div class="btn-group w100">
                    <a href="{{url('/topic/create')}}" class="btn btn-primary btn-lg btn-inverted w100">
                        <i class="fa fa-paint-brush" aria-hidden="true"></i>  新 建 话 题
                    </a>
                </div>
            </div>
            <div class="panel panel-default corner-radius panel-hot-topics">
                <div class="panel-heading text-center">
                    <h3 class="panel-title">热门话题</h3>
                </div>
                <div class="panel-body">
                    <ul class="list">
                        <li>
                            <a href="#" class="popover-with-html" data-content="讲讲我对 Laravel Policy 的认识" data-original-title="" title="">
                                讲讲我对 Laravel Policy 的认识
                            </a>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </div>
@endsection

@section('js')
    <script>
        $(document).ready(function () {
            $('body').css("background-color", "whitesmoke");
            $('body').css("height", "10px");
            $('.popover-with-html').hover(function () {
                $('.popover-with-html').popover({
                    html : true,
                    trigger : 'hover',
                    container: 'body',
                    placement: 'auto top'
                });
            });
        });
    </script>
@endsection